Use g_ascii_formatd when formatting custom paper sizes, since cups doesn't
authorMatthias Clasen <mclasen@redhat.com>
Wed, 12 Mar 2008 01:34:34 +0000 (01:34 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 12 Mar 2008 01:34:34 +0000 (01:34 +0000)
2008-03-11  Matthias Clasen  <mclasen@redhat.com>

        * modules/printbackends/cups/gtkprintbackendcups.c: Use
        g_ascii_formatd when formatting custom paper sizes, since
        cups doesn't handle , as decimal separator.  (#521548)

svn path=/trunk/; revision=19762

ChangeLog
modules/printbackends/cups/gtkprintbackendcups.c

index adcd947e0345303480931ad079c8dbdc64731a59..8290f87e91cb8a9f1359e1a820521f877a406d3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-11  Matthias Clasen  <mclasen@redhat.com>
+
+       * modules/printbackends/cups/gtkprintbackendcups.c: Use
+       g_ascii_formatd when formatting custom paper sizes, since
+       cups doesn't handle , as decimal separator.  (#521548)
+
 2008-03-11  Tor Lillqvist  <tml@novell.com>
 
        Bug 469868 - Filenames with colon ":" are not saved correctly
index c7cf6778077a8aaba1d3aacb858d0cee8f64851a..a310bc3e65b06ed0e6012e2f590c9ebee2dbdee9 100644 (file)
@@ -2464,10 +2464,12 @@ cups_printer_get_options (GtkPrinter           *printer,
       else
         {
           gchar *custom_name;
+         char width[G_ASCII_DTOSTR_BUF_SIZE];
+         char height[G_ASCII_DTOSTR_BUF_SIZE];
 
-         custom_name = g_strdup_printf (_("Custom %.2fx%.2f"),
-                                        gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS),
-                                        gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS));
+         g_ascii_formatd (width, sizeof (width), "%.2f", gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS));
+         g_ascii_formatd (height, sizeof (height), "%.2f", gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS));
+         custom_name = g_strdup_printf (_("Custom %sx%s"), width, height);
           strncpy (option->defchoice, custom_name, PPD_MAX_NAME);
           g_free (custom_name);
         }
@@ -2977,9 +2979,12 @@ cups_printer_prepare_for_print (GtkPrinter       *printer,
     gtk_print_settings_set (settings, "cups-PageSize", ppd_paper_name);
   else
     {
-      char *custom_name = g_strdup_printf ("Custom.%2fx%.2f",
-                                          gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS),
-                                          gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS));
+      char width[G_ASCII_DTOSTR_BUF_SIZE];
+      char height[G_ASCII_DTOSTR_BUF_SIZE];
+
+      g_ascii_formatd (width, sizeof (width), "%.2f", gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS));
+      g_ascii_formatd (height, sizeof (height), "%.2f", gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS));
+      char *custom_name = g_strdup_printf (("Custom.%sx%s"), width, height);
       gtk_print_settings_set (settings, "cups-PageSize", custom_name);
       g_free (custom_name);
     }